#ifndef WXTPLATFORMDEVICE_H
#define WXTPLATFORMDEVICE_H
#include "Device/BaseDevice.h"
#include <QObject>
//#include "CommonType.h"
//#include "iot_se_vendor.h"
//#include "System/System.h"
//#include "Encrypt/SM4Encrypt.h"
#include "Command/WXTProtocol/WXTAuthenticationCmd.h"
#include "Command/WXTProtocol/WXTLoginLewinCmd.h"


#include <QtNetwork/QHostInfo>


class WXTPlatformDevice: public BaseInterface<WXTPlatformDevice>
{
    Q_OBJECT
public:
    Q_INVOKABLE explicit WXTPlatformDevice(QObject *parent = 0);
    quint32 issue_device(void);
    QByteArray build_messageAuth_Request_Data();
    void sendIssueKeyAuthentication(QByteArray token);
    void sendLoginPlatform();
    void sendP7MessageAuth();

    void loginLewinCmdHandle(PortStruct source, QSharedPointer<BaseCmd> sharedCmd);
    void authenticationCmdHanle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void issueKeyCmdHanle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void messageAuthenticationCmdHanle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    QByteArray getCloudToken();
public slots:
    int messageEncrypt();
private :
    QByteArray build_P7MessageAuth_Request_Data();
    QString getLocalIpAddresses();
    QMap<QByteArray,QByteArray> getHead(QByteArray token);
     WXTProtocol *wxtProtocol;
     char m_szSeId[256];
     //SEAPPINFO m_stSeAppInfo;
     char m_enCode[128];
     unsigned char m_SignedData[8192];
     QTimer* timer;
     qint32 nRet;
     void* hEnv;
    QByteArray m_CloudToken;

private slots:
    void timeoutSlot();
    void onReceiveSM4InitComplete();


};

#endif // WXTPLATFORMDEVICE_H
